# load data
literature <- here("Data", "literature.csv") %>%
read_csv() %>%
filter(cite_weight > 0)
node_attributes <- read_csv(here("data", "node_attributes.csv"))There are multiple packages to work with networks, but the most popular is igraph because it’s flexible and easy. Other packages include sna and networks.
To use igraph functions, we first need to create an igraph object. We can use the graph_from_data_frame function, which takes two arguments: d, a data frame with the edge list in the first two columns; and vertices, a data frame with node data with the node label in the first column. (igraph calls the nodes vertices, but it’s exactly the same thing.)
g <- graph_from_data_frame(d = literature %>%
dplyr::select(from, to, everything())#, vertices = node_attributes
)
g## IGRAPH 0b24a08 DN-- 57 66 --
## + attr: name (v/c), core (e/l), edge (e/c), cites (e/c),
## | cites_empirical (e/c), mechanism (e/c), cite_weight (e/n),
## | cite_weight_empirical (e/n)
## + edges from 0b24a08 (vertex names):
## [1] computers ->detect gerrymandering
## [2] computers ->public participation
## [3] number of competitive districts ->preserve communities of interest
## [4] partisan advantage ->proportionality
## [5] partisan gerrymandering ->efficiency gap
## [6] preserve communities of interest->constitutional test
## + ... omitted several edges
| name |
|---|
| computers |
| number of competitive districts |
| partisan advantage |
| partisan gerrymandering |
| preserve communities of interest |
| mean-median vote comparison |
| majority minority districts |
| redistricting commission |
| change in constituency boundaries |
| competitiveness |
| sorting |
| contiguity |
| electorate composition change |
| house-senate delegation alignment |
| stability in voters’ fellow constituents |
| voter information about their district |
| geographic partisan distribution |
| proportionality |
| compactness |
| efficiency gap |
| equal population |
| redistricting by courts |
| upcoming redistricting |
| partisan dislocation |
| wasted votes |
| identification with governing party |
| detect gerrymandering |
| public participation |
| constitutional test |
| instability |
| elite polarization |
| number of minority representatives |
| voter turnout |
| partisan donor advantage |
| legislator voting |
| legislative outcomes |
| incumbent vote share |
| personal vote |
| pork spending |
| voter sense of place |
| rolloff |
| turnout |
| split ticket voting |
| campaign resource allocation |
| floor votes align with district preferences |
| floor votes align with state preferences |
| minority representation |
| majority representation |
| elite ideological moderation |
| legislative majority-seeking behavior |
| candidate quality |
| efficiency principle |
| ideological representation |
| support for redistricting process |
| issue salience |
| degree of political conflict |
| inequality of opportunity vs outcome |
From this igraph object, one can use igraph functions to generate network statistics. However, this involves several steps and the output is not tidy. To simplify generating network statistics from literature reviews, we introduce the netlit package.
netlit R PackageThe netlit package provides functions to generate network statistics from a literature review. Specifically, netlit provides a wrapper for igraph functions to facilitate using network analysis in literature reviews.
Install this package with
devtools::install_github("judgelord/netlit")
To install netlit from CRAN, run the following:
The review() function takes in a dataframe, data, that includes from and to columns (a directed graph structure).
In the example below, we use example data from this project on redistricting. These data are a set of related concepts (from and to) in the redistricting literature and citations for these relationships (cites and cites_empirical). See vignette("netlit") for more details on this example.
## # A tibble: 6 x 4
## to from cites cites_empirical
## <chr> <chr> <chr> <chr>
## 1 detect gerrymandering computers Altman & McDona~ Wang 2016
## 2 public participation computers Altman & McDona~ <NA>
## 3 preserve communities of interest number of~ Gimpel & Harbri~ Gimpel & Harbrid~
## 4 proportionality partisan ~ Caughey et al. ~ <NA>
## 5 efficiency gap partisan ~ Chen 2017 Chen 2017
## 6 constitutional test preserve ~ Stephanopoulos ~ <NA>
netlit offers four functions: make_edgelist(), make_nodelist(), augment_nodelist(), and review().
review() is the primary function (and probably the only one you need). The others are helper functions that perform the individual steps that review() does all at once. review() takes in a dataframe with at least two columns representing linked concepts (e.g., a cause and an effect) and returns data augmented with network statistics. Users must either specify “from” nodes and “to” nodes with the from and to arguments or include columns named from and to in the supplied data object.
review() returns a list of three objects:
edgelist (a list of relationships with edge_betweenness calculated),nodelist (a list of concepts with degree and betweenness calculated), andgraph object suitable for use in other igraph functions or other network visualization packages.Users may wish to include edge attributes (e.g., information about the relationship between the two concepts) or node attributes (information about each concept). We show how to do so below. But first, consider the basic use of review():
## A netlit_review object with the following components:
##
## $edgelist
## - 69 edges
## - edge attributes: edge_betweenness
## $nodelist
## - 57 nodes
## - node attributes: degree, betweenness
## $graph
## an igraph object
## # A tibble: 6 x 3
## from to edge_betweenness
## <chr> <chr> <dbl>
## 1 computers detect gerrymandering 2
## 2 computers public participation 1
## 3 number of competitive districts preserve communities of int~ 88
## 4 partisan advantage proportionality 19.5
## 5 partisan gerrymandering efficiency gap 13.5
## 6 preserve communities of interest constitutional test 7
## node degree betweenness
## 1 computers 0 0.0
## 2 number of competitive districts 1 66.0
## 3 partisan advantage 6 113.5
## 4 partisan gerrymandering 1 42.0
## 5 preserve communities of interest 2 81.0
## 6 mean-median vote comparison 0 0.0
Edge and node attributes can be added using the edge_attributes and node_attributes arguments. edge_attributes is a vector that identifies columns in the supplied data frame that the user would like to retain. node_attributes is a separate dataframe that contains attributes for each node in the primary data set. The example node_attributes data include one column type indicating a type for each each node/variable/concept.
## # A tibble: 6 x 2
## node type
## <chr> <chr>
## 1 Alignment of floor vote breakdown with statewide majority of voters effect
## 2 bipartisan gerrymander policy
## 3 campaign resource allocation effect
## 4 campaign spending effect
## 5 candidate quality effect
## 6 change in constituency boundaries condition
lit <- review(literature,
edge_attributes = c("cites", "cites_empirical"),
node_attributes = node_attributes)
lit## A netlit_review object with the following components:
##
## $edgelist
## - 69 edges
## - edge attributes: cites, cites_empirical, edge_betweenness
## $nodelist
## - 57 nodes
## - node attributes: type, degree, betweenness
## $graph
## an igraph object
## # A tibble: 6 x 5
## from to cites cites_empirical edge_betweenness
## <chr> <chr> <chr> <chr> <dbl>
## 1 computers detec~ Altm~ Wang 2016 2
## 2 computers publi~ Altm~ <NA> 1
## 3 number of competitive districts prese~ Gimp~ Gimpel & Harbr~ 88
## 4 partisan advantage propo~ Caug~ <NA> 19.5
## 5 partisan gerrymandering effic~ Chen~ Chen 2017 13.5
## 6 preserve communities of interest const~ Step~ <NA> 7
## node type degree betweenness
## 1 computers condition 0 0.0
## 2 partisan advantage goal 6 113.5
## 3 partisan gerrymandering condition 1 42.0
## 4 preserve communities of interest goal 2 81.0
## 5 mean-median vote comparison metric 0 0.0
## 6 majority minority districts policy 0 0.0
Tip: to retain all variables from literature, use edge_attributes = names(literature).
Additional columns in the redistricting literature data include discriptions of the edge (the relationship between the to and from concepts), the theorized mechanism, and cite_weight—the number of studies in the literature that cite that that causal relationship.
# load expanded dataset
literature <- read_csv(here::here("data", "literature.csv"))
# now with all node and edge attributes
lit <- review(literature,
edge_attributes = names(literature),
node_attributes = node_attributes
)
edges <- lit$edgelist
kablebox(edges)| from | to | core | edge | cites | cites_empirical | mechanism | cite_weight | cite_weight_empirical | edge_betweenness |
|---|---|---|---|---|---|---|---|---|---|
| computers | detect gerrymandering | TRUE | increases, imperfectly | Altman & McDonald 2010; Wang 2016; Altman & McDonald 2011; Ramachandran & Gold 2018 | Wang 2016 | Altman and McDonald (2010) argue that simulations cannot adequately detect gerrymanders. Wang proposes three tests to detect the effects and intents of gerrymanders. Altman and McDonald (2011) provide an open source program for redistricting analysis. Ramachandran & Gold argue that simulation-based measures (part of “outlier analysis”) are some of the only ways to effectively detect gerrymanders. | 4 | 1 | 2.0 |
| computers | public participation | TRUE | increases | Altman & McDonald 2010; Altman & McDonald 2011 | NA | Altman & McDonald argue that computers can be used to allow the public to participate in the map-drawing process by soliciting information and education about redistricting. | 2 | 0 | 1.0 |
| number of competitive districts | preserve communities of interest | TRUE | decreases if cor(party, community)>0 | Gimpel & Harbridge-Yong 2020 | Gimpel & Harbridge-Yong 2020 | If racial groups or like municipal jurisdictions have partisan leanings, then creating more competitive districts often means splitting communities across districts. | 1 | 1 | 88.0 |
| partisan advantage | proportionality | TRUE | decreases | Caughey et al. 2017; Tamas 2019 | NA | A partisan gerrymander aims to diverge from proportionality. | 2 | 0 | 19.5 |
| partisan gerrymandering | efficiency gap | TRUE | increases | Chen 2017 | Chen 2017 | Chen conducts simulations of neutrally drawn districts in Wisconsin and compares the efficiency gap of simulations to that of the actual redistricting plan, in order to show that the map was designed to give an advantage to one party. | 1 | 1 | 13.5 |
| preserve communities of interest | constitutional test | TRUE | NA | Stephanopoulos 2012 | NA | Stephanopoulos argues that the Supreme Court ought to adopt a test of political gerrymandering based on the “territorial community.” In short, if a district map disrupts an organic geographic community, it is unconstitutional. | 1 | 0 | 7.0 |
| mean-median vote comparison | detect gerrymandering | TRUE | NA | McDonald & Best 2015; Wang 2016; Wang 2016b | Wang 2016b | McDonald & Best propose a new measure of detecting gerrymanders; compare a party’s median vote share in a district to its mean vote share. Wang proposes a similar measure of gerrymandering based on comparing mean and median vote shares. | 3 | 1 | 2.0 |
| mean-median vote comparison | constitutional test | TRUE | NA | McDonald & Best 2015, Best et al. 2018 | NA | McDonald & Best argue that their measure of gerryamndering can be extended to identify which gerrymanders are unconstitutional | 1 | 0 | 1.0 |
| partisan gerrymandering | constitutional test | TRUE | NA | Kang 2017 | NA | Kang argues that it is unconstitutional for the government to take partisanship into account when determining district lines | 1 | 0 | 1.0 |
| partisan gerrymandering | instability | TRUE | increases | Yoshinaka & Murhpy 2011 | Yoshinaka & Murhpy 2011 | Partisan mapmakers can create political instability, particularly for their opponent legislators, by breaking the link between representatives and constituents | 1 | 1 | 8.0 |
| partisan gerrymandering | elite polarization | TRUE | no effect | Masket et al. 2012 | Masket et al. 2012 | Masket et al. find that partisan redistricting do not have much effect on legislative polarization, as it is swamped by other factors | 1 | 1 | 2.0 |
| majority minority districts | number of minority representatives | TRUE | increases | Atsusaka 2021 | Atsusaka 2021 | Where minorities are a majority, they are have a better chance of electing a representative; Atsusaka 2021 creates a logical model that allows minority candidate appearance to be a result of (1) the electoral performance of coethnic candidates in the most recent elections and (2) the racial composition of a district. | 1 | 1 | 1.0 |
| majority minority districts | partisan advantage | TRUE | decreases | Cox & Holden 2011; Sabouni & Shelton 2021 | Sabouni & Shelton 2021 | Cox and Holden argue that the optimal gerrymandering strategy is to cluster your strong partisan supporters into districts with a smaller number of strong partisan opponents. Thus, the Voting Rights Act’s majority-minority districts limit Republicans’ ability to effectively gerrymander. Sabouni and Shelton find that states that must submit their maps for clearance under the VRA had greater consistency in maps before and after the 2010 redistricting wave. | 2 | 1 | 24.0 |
| majority minority districts | voter turnout | TRUE | increases | Fraga 2016 | Fraga 2016 | African Americans are more likely to vote when reassigned to a majority black district. Fraga relies on a theoretical “empowerment framework,” in which members of minority groups are more likely to participate when their group has representation and influence in politics. | 1 | 1 | 1.0 |
| redistricting commission | partisan advantage | TRUE | decrease | Cain 2011 | NA | Cain argues that independent citizen redistricting commissions are less likely to produce extremely partisan maps because they need to satisfy a supermajority by compromising on various redistricting criteria. | 1 | 0 | 23.0 |
| partisan gerrymandering | partisan donor advantage | NA | increases | Kirkland 2013 | Kirkland 2013 | Parties care about other resources in addition to votes, such as donations. They can use redistricting to concentrate likely donors into their districts and remove them from opponents’ districts, thus increasing their odds of reelection. | 1 | 1 | 8.0 |
| change in constituency boundaries | legislator voting | NA | no effect, affects | Bertelli & Carson 2011, Hayes et al. 2010 | Bertelli & Carson 2011, Hayes et al. 2010 | Bertelli and Carson argue that partisan gerrymandering is a form of risk-sharing, in which individual members do not have to radically change their positions while maintaining their odds of reelection. In contrast, Hayes et al. say that legislators respond to the demographic changes of their constituency after redistricting. | 1 | 1 | 1.0 |
| change in constituency boundaries | legislative outcomes | NA | affects | Bertelli & Carson 2011, Gul & Pesendorfer 2010 | Bertelli & Carson 2011 | Bertelli & Carson: Partisan gerrymandering helps the majority party achieve its policy goals by increasing the odds of electoral success without requiring much sacrifice by individual members. Gul & Pesendorfer: use formal theory to show that policy outcomes are biased towards the redistricting party | 1 | 1 | 1.0 |
| competitiveness | voter turnout | NA | no effect | Moskowitz & Schneer 2019; Hunt 2018 | Moskowitz & Schneer 2019; Hunt 2018 | Moskowitz & Schneer 2019: Residents of competitive districts systematically differ from those in non-competitive districts, leading cross-sectional studies to erroneously find a relationship between competitiveness and turnout. In addition, most voters aren’t aware of the competitiveness of their House race. Hunt 2018: examines data from Florida during 2012 election and finds that change in competitiveness after redistricting has a small effect on turnout | 2 | 2 | 3.0 |
| sorting | elite polarization | NA | increases | Krasa & Polborn 2018 | Krasa & Polborn 2018 | Krasa & Polborn 2018: electoral competition model where gerrymandering (“intensification of the median ideological preferences in some districts”) can result in increased partisan polarization | 1 | 1 | 1.0 |
| contiguity | partisan advantage | NA | increases | Chen & Rodden 2013 | Chen & Rodden 2013 | Democrats’ concentration in cities leads to a Republican bias, due to the geographic, majoritarian nature of U.S. elections. | 1 | 1 | 24.0 |
| electorate composition change | incumbent vote share | NA | decreases | Hood & McKee 2013; Ansolabehere & Snyder 2012 | Hood & McKee 2013; Ansolabehere & Snyder 2012 | Hood and McKee find that redistricting destroys the connection between a representative and their constituents; the new constituents have no such bond, so incumbency advantage is lower. Ansolabehere and Snyder find similar results when comparing the vote margins of districted and non-districted incumbents. | 2 | 2 | 2.0 |
| electorate composition change | personal vote | NA | decreases | Carsey et al. 2017, Bertelli & Carson 2011 | Carsey et al. 2017 | When a legislator’s district changes, the personal connection with some of their constituents is lost. Thus, legislators are less able to convert supporters of the opposite party, as they have no connections with their new constituents. | 1 | 1 | 2.0 |
| house-senate delegation alignment | pork spending | NA | decreases | Chen 2010 | NA | NA | 1 | 0 | 12.0 |
| stability in voters’ fellow constituents | voter sense of place | NA | increases heterogeneously by race | Hayes & McKee 2011 | Hayes & McKee 2011 | NA | 1 | 1 | 9.0 |
| change in constituency boundaries | voter information about their district | NA | affects | Winburn & Wagner 2010 | NA | NA | NA | NA | 4.0 |
| voter information about their district | rolloff | NA | decreases | Winburn & Wagner 2010 | Winburn & Wagner 2010 | NA | 1 | 1 | 2.0 |
| voter information about their district | turnout | NA | decreases | Winburn & Wagner 2010 | Winburn & Wagner 2010 | NA | 1 | 1 | 10.0 |
| voter information about their district | split ticket voting | NA | increases | Winburn & Wagner 2010 | Winburn & Wagner 2010 | NA | 1 | 1 | 10.0 |
| electorate composition change | campaign resource allocation | NA | no effect | Limbocker & You 2020 | Limbocker & You 2020 | Candidates have their own campaign style, so their resource allocation decisions do not change even when the electoral circumstances change. | 1 | 1 | 2.0 |
| geographic partisan distribution | partisan advantage | NA | affects | Chen & Rodden 2013; Duchin et al. 2019; Powell et al. 2020 | Chen & Rodden 2013; Duchin et al. 2019; Powell et al. 2020 | Chen & Rodden 2013: Democrats are geographically clustered which is electorally disadvantageous; they run up the score in large cities which leads to a discrepency between total vote share and seat share. Duchin et al. 2019: Republicans in Massachusetts are evenly distributed across the state, so they can get 30-40% of the statewide vote, but never win a single House seat. Powell et al. 2020: Also find that geographic clustering plays a role in the discrepency between total vote share and seat distribution in the House. | 3 | 3 | 24.0 |
| preserve communities of interest | stability in voters’ fellow constituents | NA | increases | Winburn & Wagner 2010 | NA | NA | 1 | 0 | 16.0 |
| preserve communities of interest | voter information about their district | NA | increases | Winburn & Wagner 2010 | NA | NA | 1 | 0 | 24.0 |
| preserve communities of interest | rolloff | NA | decreases heterogeneously by race | Hayes & McKee 2011; Winburn & Wagner 2010 | Hayes & McKee 2011 | NA | 2 | 1 | 8.0 |
| number of competitive districts | elite polarization | NA | decreases | Grainger 2010 | Grainger 2010 | Safe partisan seats tend to increase partisan polarization. | 1 | 1 | 1.0 |
| partisan advantage | floor votes align with district preferences | NA | decreases | Caughey et al. 2017 | NA | TODO | 1 | 0 | 8.0 |
| partisan advantage | floor votes align with state preferences | NA | decreases | Caughey et al. 2017 | NA | TODO | 1 | 0 | 8.0 |
| partisan advantage | partisan advantage | NA | NA | Arrington 2016; Campisi et al. 2019; Katz, King & Rosenblatt 2020 | NA | Measures of partisan symmetry/bias/advantage | 3 | 0 | 0.0 |
| partisan advantage | legislator voting | NA | no effect | Lo 2013 | Lo 2013 | Legislators do not change their ideological positions after redistricting (though The Electoral Connection suggests they should) | 1 | 1 | 8.0 |
| partisan advantage | elite polarization | NA | no effect | Lo 2013 | NA | Because vulnerable legislators do not moderate their positions, Lo assumes that safe legislators do not become more extreme | 1 | 0 | 5.0 |
| partisan advantage | efficiency gap | NA | no effect | Chen & Cottrell 2016 | Chen & Cottrell 2016 | Gerrymandering does not affect the electoral results in most states, and in the states where it does have an effect, the effect is small. Republicans are expected to net only one additional seat in Congress due to gerrymandering. | 1 | 1 | 15.0 |
| partisan advantage | number of competitive districts | NA | increases | Goedert 2017; Goedert 2014 | Goedert 2017, Yoshinaka & Murhpy 2011; Goedert 2014 | Large changes in the national partisan tide causes garrymanders to backfire on the map-drawing party (an effect known as the “dummymander”), as their members face unexpectedly competitive elections. | 2 | 2 | 73.0 |
| proportionality | house-senate delegation alignment | NA | increases | Chen 2010 | NA | NA | 1 | 0 | 22.0 |
| compactness | minority representation | NA | decreases | Webster 2013 | NA | Webster 2013: citing earlier research, Webster posits that compactness hinders a map drawer’s ability to create districts for historically underrepresented groups. | 1 | 0 | 1.0 |
| compactness | compactness | NA | NA | Barnes & Solomon 2020; Gatesman & Unwin 2021; Magleby & Mosesson 2018; De Assis et al. 2014; Altman & McDonald 2011; Lie et al. 2016, Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 | Barnes & Solomon 2020; Magleby & Mosesson 2018; De Assis et al. 2014; Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 | Barnes & Solomon 2020: measuring compactness can have associated flexibility that can be abused (geography, topography, cartographic projections, and resolution); Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics.De Assis et al. 2014: Greedy randomized adaptive search procedure can balance multiple criteria, including compactness. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including redistricting. Liu et al.; propose a method of parallel evolutionary computation to solve the optimization problem of redistricting. Chen & Rodden; simulation-based method also takes compactness into account to draw district maps and identify gerrymanders. Tam Cho & Liu; use compactness in their redistricting algorithm. Saxon 2020: software for applying compactness/contiguity/equipopulation objectives to evaluate maps – specific focus on different definitions of compactness. | 6 | 4 | 0.0 |
| efficiency gap | efficiency gap | NA | NA | Stephanopoulos & McGhee 2015, McGhee 2014 | McGhee 2014 | Stephanopoulos and McGhee propose a measure of partisan symmetry to be adopted by the courts, in order to limit partisan influence over redistricting; McGhee distinguishes efficiency from related concepts of symmetry and responsiveness | 1 | 1 | 0.0 |
| equal population | equal population | NA | NA | Gatesman & Unwin 2021; Magleby & Mosesson 2018 | Magleby & Mosesson 2018 | Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including equality of population | 2 | 1 | 0.0 |
| redistricting commission | majority representation | NA | no effect | Matsusaka 2010 | Matsusaka 2010 | Matsusaka does not discuss a mechanism for this relationship, but finds that other electoral rules, such as campaign finance regulations and ballot access rules, are also not associated with greater congruence between public opinion and legislative behavior. | 1 | 1 | 1.0 |
| redistricting commission | elite ideological moderation | NA | increases | McGhee & Shor 2017 | McGhee & Shor 2017 | McGhee and Shor focus on the effect of the Top Two primary on elite moderation, but argue that the introduction of independent redistricting commissions may also lead to greater moderation by creating more competitive districts. | 1 | 1 | 1.0 |
| redistricting commission | competitiveness | NA | increases, no effect | Carson et al. 2014, Grainger 2010, Masket et al. 2012; Goedert 2014 | Carson et al. 2014, Grainger 2010, Masket et al. 2012; Goedert 2014 | Carson et al.: increased ideological polarization and the availability of redistricting computer software encourages elites to draw non-competitive districts in order to increase their odds of reelection. Masket et al.: partisan redistricting does not effect competition much and is swamped by other factors. Williamson 2019: redistricting commissions produce fewer uncontested elections, relative to partisan redistrcting. | 2 | 2 | 2.0 |
| redistricting by courts | competitiveness | NA | increases | Carson et al. 2014 | Carson et al. 2014 | NA | 1 | 1 | 2.0 |
| upcoming redistricting | legislative majority-seeking behavior | NA | increases | Makse 2014 | Makse 2014 | Parties have a greater incentive to become the majority party in the state legislature if redistricting is imminent and controlled by the legislature, as they can then determine the new district boundaries | 1 | 1 | 1.0 |
| partisan dislocation | partisan dislocation | NA | NA | Deford, Eubank & Rodden 2020 | NA | Deford, Eubank & Rodden 2020: new measure “partisan dislocation” which proxies for cracking/packing | 1 | 0 | 0.0 |
| compactness | turnout | NA | NA | Ladewig 2018 | Ladewig 2018 | Ladewig 2018 posits and tests that geographical compactness can affect electoral turnout, and tests this on two redistricting cycles. Posited mechanisms include functional ones (easier linkage between politicians and constituents), institutional (decreased investment in non-salient elections, which are brought about by weakened tied communities that are not compact) and normative (citizens who live in gerrymandered districts might be less invested in democratic process). | NA | NA | 1.0 |
| preserve communities of interest | preserve communities of interest | NA | NA | Makse 2012 | Makse 2012 | Makse 2012 proposes using initiative data at polling station to get at latent patterns of voting in districts as a way to measure communities of interest. | NA | NA | 0.0 |
| partisan gerrymandering | partisan advantage | NA | increases | Wang 2016; Cox & Holden 2011; Sabouni & Shelton 2021; Powell et al. 2020 | Cox & Holden 2011; Sabouni & Shelton 2021; Powell et al. 2020 | The party in charge of the redistricting process draws maps to secure an electoral advantage. | 4 | 3 | 25.5 |
| preserve communities of interest | partisan gerrymandering | NA | decreases | Sabouni & Shelton 2021 | Sabouni & Shelton 2021 | Some traditional districting principles, like preserving communities of interest, can constrain partisan gerrymandering. Authors measure this by examining the degree of overlap of districts before and after the 2010 wave of redistricting. | 1 | 1 | 49.0 |
| redistricting commission | candidate quality | NA | increases | Williamson 2019 | Williamson 2019 | Commission-based redistricting leads to more races with quality candidates (candidates who have held office previously), because quality candidates are more confident that they can win if the map has not been subject to partisan manipulation. | 1 | 1 | 1.0 |
| efficiency gap | efficiency principle | NA | fails | Veomett 2018 | NA | Veomett 2018 shows that, under unequal voter turnout, the efficiency gap does not satisfy the efficiency principle (it cannot distinguish between two outcomes, in which a party receives the same vote share but different seat shares). | 1 | 0 | 10.0 |
| wasted votes | efficiency gap | NA | increases | McGhee 2017 | NA | Only measures based on wasted votes can capture the concept of the efficiency gap. Symmetry-based measures fail to capture the concept. | 1 | 0 | 6.0 |
| efficiency gap | ideological representation | NA | affects | Caughey et al. 2017b | Caughey et al. 2017b | A higher efficiency gap indicates that one party gains additional seats in the legislature, which can then be used to achieve the party’s policy goals. | 1 | 1 | 10.0 |
| identification with governing party | support for redistricting process | NA | increases | Fougere et al. 2010 | Fougere et al. 2010 | Survey respondents who identify with the party in control of their state government are more likely to approve of their redistricting process and view it as fair. | 1 | 1 | 1.0 |
| redistricting commission | support for redistricting process | NA | increases | Fougere et al. 2010 | Fougere et al. 2010 | Survey respondents living in states with partisan control over the redistricting process were less likely to view the process as fair. | 1 | 1 | 1.0 |
| efficiency gap | proportionality | NA | NA | Warrington 2018 | NA | Warrington argues that the efficiency gap metric reduces to proportional representation, which is not a constitutional right. Therefore, the efficiency gap is not a useful metric for identifying unconstitutional gerrymanders. | 1 | 0 | 10.5 |
| change in constituency boundaries | issue salience | NA | affects | Gardner 2012 | NA | Because we divide the electorate according to geography, local issues (issues of place) become more important than issues that are unrelated to place. | 1 | 0 | 1.0 |
| change in constituency boundaries | degree of political conflict | NA | affects | Gardner 2012 | NA | Districts can be drawn such that the electorate within each district is homogeneous or heterogeneous (along some relevant political dimension). The more heterogeneous the district, the greater likelihood of political conflict. | 1 | 0 | 1.0 |
| partisan gerrymandering | majority representation | NA | affects | Goedert 2014; Nagle 2019 | NA | Goedert 2014: The type of gerrymander (bipartisan, nonpartisan, partisan) can affect two aspects of representation: bias and responsiveness. Nagle 2019: Gerrymandering in Pennsylvania hinders responsiveness, so responsiveness ought to be its own redistricting criteria. | 2 | 0 | 7.0 |
| detect gerrymandering | inequality of opportunity vs outcome | NA | NA | Wang et al. 2018 | NA | Wang et al. 2018: We can divide measures of gerrymandering into two categories: those that identify inequality of opportunity and those that identify inequality of outcome | 1 | 0 | 3.0 |
| change in constituency boundaries | electorate composition change | NA | increases | Bertelli & Carson 2011; Hood & McKee 2013; Ansolabehere & Snyder 2012 | NA | Changing the boundaries of a district will necessarily cange who is in the district, but the reverse is not necessarily true. A electorate can change without the district boundaries changing. | 3 | 0 | 4.0 |
| node | type | degree | betweenness |
|---|---|---|---|
| computers | condition | 0 | 0.0 |
| partisan advantage | goal | 6 | 113.5 |
| partisan gerrymandering | condition | 1 | 42.0 |
| preserve communities of interest | goal | 2 | 81.0 |
| mean-median vote comparison | metric | 0 | 0.0 |
| majority minority districts | policy | 0 | 0.0 |
| redistricting commission | policy | 0 | 0.0 |
| change in constituency boundaries | condition | 0 | 0.0 |
| competitiveness | goal | 2 | 2.0 |
| sorting | condition | 0 | 0.0 |
| contiguity | condition | 0 | 0.0 |
| electorate composition change | condition | 1 | 3.0 |
| stability in voters’ fellow constituents | effect | 1 | 8.0 |
| voter information about their district | effect | 2 | 19.0 |
| proportionality | goal | 2 | 20.0 |
| equal population | metric | 1 | 0.0 |
| redistricting by courts | policy | 0 | 0.0 |
| upcoming redistricting | condition | 0 | 0.0 |
| detect gerrymandering | goal | 2 | 2.0 |
| public participation | goal | 1 | 0.0 |
| constitutional test | metric | 3 | 0.0 |
| instability | effect | 1 | 0.0 |
| elite polarization | effect | 4 | 0.0 |
| number of minority representatives | effect | 1 | 0.0 |
| voter turnout | effect | 2 | 0.0 |
| legislator voting | effect | 2 | 0.0 |
| legislative outcomes | effect | 1 | 0.0 |
| incumbent vote share | effect | 1 | 0.0 |
| personal vote | effect | 1 | 0.0 |
| pork spending | policy | 1 | 0.0 |
| voter sense of place | effect | 1 | 0.0 |
| rolloff | effect | 2 | 0.0 |
| turnout | effect | 2 | 0.0 |
| split ticket voting | effect | 1 | 0.0 |
| campaign resource allocation | effect | 1 | 0.0 |
| floor votes align with district preferences | effect | 1 | 0.0 |
| minority representation | effect | 1 | 0.0 |
| elite ideological moderation | effect | 1 | 0.0 |
| legislative majority-seeking behavior | effect | 1 | 0.0 |
| candidate quality | effect | 1 | 0.0 |
| house-senate delegation alignment | NA | 1 | 11.0 |
| number of competitive districts | NA | 1 | 66.0 |
| issue salience | NA | 1 | 0.0 |
| geographic partisan distribution | NA | 0 | 0.0 |
| inequality of opportunity vs outcome | NA | 1 | 0.0 |
| compactness | NA | 1 | 0.0 |
| efficiency gap | NA | 4 | 25.5 |
| partisan donor advantage | NA | 1 | 0.0 |
| majority representation | NA | 2 | 0.0 |
| ideological representation | NA | 1 | 0.0 |
| partisan dislocation | NA | 1 | 0.0 |
| wasted votes | NA | 0 | 0.0 |
| identification with governing party | NA | 0 | 0.0 |
| efficiency principle | NA | 1 | 0.0 |
| support for redistricting process | NA | 2 | 0.0 |
| floor votes align with state preferences | NA | 1 | 0.0 |
| degree of political conflict | NA | 1 | 0.0 |
igraph object## IGRAPH 0bc61a5 DN-B 57 69 --
## + attr: name (v/c), type (v/c), degree (v/n), betweenness (v/n), core
## | (e/l), edge (e/c), cites (e/c), cites_empirical (e/c), mechanism
## | (e/c), cite_weight (e/n), cite_weight_empirical (e/n),
## | edge_betweenness (e/n)
## + edges from 0bc61a5 (vertex names):
## [1] computers ->detect gerrymandering
## [2] computers ->public participation
## [3] number of competitive districts->preserve communities of interest
## [4] partisan advantage ->proportionality
## [5] partisan gerrymandering ->efficiency gap
## + ... omitted several edges
What does it mean?
D means directedN means named graphW means weighted graphname (v/c) means name is a node attribute and it’s a charactercite_weight (e/n) means cite_weight is an edge attribute and it’s numericigraph::plot()The plot() function works out of the box, but the default options are often not ideal:
For plotting options, you can check ?igraph.plotting. For example, we can set the vertex color, label colors, the size of the labels, curvature to the edge and edge color.
plot(g,
vertex.color = "grey", # change color of nodes
vertex.label.color = "black", # change color of labels
vertex.label.cex = .25, # change size of labels to 25% of original size
edge.curved=.25, # add a 25% curve to the edges
arrow.size = .2,
edge.color="grey20") # change edge color to greyggnetworkWe can also plot using the package ggnetwork to tidy the igraph object so that we can use ggplot.
# install.packages("ggnetwork")
library(ggnetwork)
# use ggnetwork to tranform the igraph object into tidy data
n <- ggnetwork(g)
# clean up text for better visualization
n %<>%
mutate(cites = cites %>% str_remove(",.*|;.*"))
n$name %<>% str_replace(" ", "\n")
n$name %<>% str_replace(" ([A-z]*)$", "\n\\1")
n$cite_weight %<>% replace_na(0)
n %<>% mutate(partisan = str_detect(name, "partisan"),
empirical = ifelse(!is.na(cites_empirical),
"Empirical work",
"No empirical work"))
n2 <- n %>% filter(partisan) %>% mutate(partisan = FALSE)
n %<>% full_join(n2) %>% mutate(partisan = ifelse(partisan, "Mentions partisanship", "Other nodes"))
set.seed(12)
n$cite_weight %<>% as_factor()
# plot tidy network data
p <- ggplot(n) +
aes(x = x, y = y, xend = xend, yend = yend,
label = name %>% str_to_title()) +
geom_nodes(size = 10, alpha = .1) +
geom_edges(aes(color = cite_weight, linetype = empirical ),
curvature = 0.1,
alpha = .8,
#box.padding = unit(1, "lines"),
arrow = arrow(length = unit(6, "pt"), type = "closed")) +
geom_nodetext_repel(size = 2.3) +
theme_blank() +
labs(color = "Number of\nPublications",
linetype = "") +
scale_color_viridis_d(option = "plasma", begin = 0, end = .9, direction = -1) +
theme(legend.position="bottom")
p# with edge text
p <- p + geom_edgetext(aes(label = cites_empirical %>% str_remove(",.*"),
color = cite_weight),
size = 2,
alpha = .2)
pFacets retain node position:
p <- ggplot(n) +
aes(x = x, y = y, xend = xend, yend = yend,
label = name %>% str_to_title()) +
geom_nodes(size = 10, alpha = .1) +
geom_edges(aes(color = cite_weight, linetype = empirical ),
curvature = 0.1,
alpha = .8,
#box.padding = unit(1, "lines"),
arrow = arrow(length = unit(6, "pt"), type = "closed")) +
geom_nodetext_repel(size = 2.3) +
theme_blank() +
labs(color = "Number of\nPublications",
linetype = "") +
scale_color_viridis_d(option = "plasma", begin = 0, end = .9, direction = -1) +
theme(legend.position="bottom")Now modify some of these plotting attributes so that they are function of network properties. For example, a common adjustment is to change the size of the nodes and node labels so that they match their importance.
Here, centrality
visnetowrklibrary(visNetwork)
# define function to plot
literature_plot <- function(lit){
nodes <- lit$nodelist %>%
mutate(id = node) %>%
filter(!is.na(id)) %>%
distinct() %>%
# removed nodes with multiple types
add_count(id) %>%
filter(n == 1)
edges <- lit$edgelist %>% transmute(
from = from,
to = to,
detail = paste(edge, mechanism, cites, sep = "<br>") %>% str_remove_all("NA"),
type = edge
) %>%
filter(!is.na(from),!is.na(to)) %>%
distinct()
# use betweeness to scale nodes
nodes$icon.size <-nodes$betweenness
# add attributes
nodes <- nodes %>% mutate(label = id,
title = paste0("<p>", type, ": ", label,"</p>"),
# levels in case we want Hierarchical Layout
level = ifelse(type == "goal", 1:2, 3:4),
# FontAwesome.com shapes for fun
shape = "icon",
icon.color = case_when(type =="goal" ~ "black",
type !="goal" ~ "black"),
icon.code = case_when(type == "condition" ~ "f205", # chess board
type == "goal" ~ "f24e", # scale "f05b", # crosshairs
type == "policy" ~ "f0e3", # gavel
type == "value" ~ "f004", # "f4be", # hand with heart
type == "effect" ~ "f080", # "f681", # data
type == "metric" ~ "f1de",# "f548", # ruler
TRUE ~ "f0c8"), #square
icon.face = "'FontAwesome'",
icon.weight = "bold")
# format edges
edges <- edges %>% mutate(
title = paste0("<p>", detail, "</p>"),
#label = type,
color = ifelse(str_detect(type, "^increase"), "#81a275", "#617d9f"),
color = ifelse(str_detect(type, "^decrease"), "#b14552", color) )
# make directed graph
visNetwork(nodes=nodes, edges=edges, width = "100%") %>%
visEdges(width=5, color= edges$color, arrows = "to", arrowStrikethrough = F, smooth = T) %>%
visNodes(scaling=list(min=40, max=50)) %>%
visOptions(highlightNearest = list(enabled = T, degree = 1, hover = T)) %>%
visInteraction(hover=TRUE, zoomView = TRUE) %>%
#visHierarchicalLayout() %>%
visPhysics(solver = "forceAtlas2Based", forceAtlas2Based = list(gravitationalConstant = -50)) %>%
addFontAwesome(name = "font-awesome-visNetwork") %>%
visLayout(randomSeed = 12) # to have always the same network
}Let’s return to igraph functions to look at descriptive statistics at the node level. All of these are in some way measures of importance or centrality.
The most basic measure is degree, the number of adjacent edges to each node. It is often considered a measure of direct influence. In the redistricting network, it will be the unique number of concepts that each concept is interacting with. Sort the degree of the network and print it out.
| x | |
|---|---|
| partisan advantage | -14 |
| partisan gerrymandering | -8 |
| preserve communities of interest | -8 |
| efficiency gap | -8 |
| redistricting commission | -6 |
| change in constituency boundaries | -6 |
Partisan advantage (degree=14), followed by a three way tie of communities preserved, partisan gerrymandering and compactness (each degree=5) are the most “central” concepts covered in the redistricting literature.
In directed graphs, there are three types of degree: indegree (incoming edges), outdegree (outgoing edges), and total degree. You can find these using mode="in" or mode="out" or mode="total".
Strength is a weighted measure of degree that takes into account the number of edges that go from one node to another. In this network, it will be the total number of interactions of each concept with any other concept. Sort the strength of the network and print it out.
| x | |
|---|---|
| partisan advantage | -14 |
| partisan gerrymandering | -8 |
| preserve communities of interest | -8 |
| efficiency gap | -8 |
| redistricting commission | -6 |
| change in constituency boundaries | -6 |
Closeness measures how many steps are required to access every other node from a given node. It’s a measure of how long information takes to arrive (who hears news first?). Higher values mean less centrality. Sort the closeness of the network (normalize it) and print it out.
## redistricting commission
## -0.03452528
## majority minority districts
## -0.03123257
## contiguity
## -0.02939633
## geographic partisan distribution
## -0.02939633
## preserve communities of interest
## -0.02895553
## partisan advantage
## -0.02889577
## partisan gerrymandering
## -0.02888087
## number of competitive districts
## -0.02868852
## change in constituency boundaries
## -0.02216944
## wasted votes
## -0.01955307
## efficiency gap
## -0.01921098
## electorate composition change
## -0.01851852
## voter information about their district
## -0.01851852
## computers
## -0.01851240
## mean-median vote comparison
## -0.01851240
## compactness
## -0.01818182
## proportionality
## -0.01817592
## redistricting by courts
## -0.01817592
## competitiveness
## -0.01785714
## sorting
## -0.01785714
## stability in voters' fellow constituents
## -0.01785714
## upcoming redistricting
## -0.01785714
## detect gerrymandering
## -0.01785714
## house-senate delegation alignment
## -0.01785714
## identification with governing party
## -0.01785714
## equal population
## -0.01754386
## public participation
## -0.01754386
## constitutional test
## -0.01754386
## instability
## -0.01754386
## elite polarization
## -0.01754386
## number of minority representatives
## -0.01754386
## voter turnout
## -0.01754386
## legislator voting
## -0.01754386
## legislative outcomes
## -0.01754386
## incumbent vote share
## -0.01754386
## personal vote
## -0.01754386
## pork spending
## -0.01754386
## voter sense of place
## -0.01754386
## rolloff
## -0.01754386
## turnout
## -0.01754386
## split ticket voting
## -0.01754386
## campaign resource allocation
## -0.01754386
## floor votes align with district preferences
## -0.01754386
## minority representation
## -0.01754386
## elite ideological moderation
## -0.01754386
## legislative majority-seeking behavior
## -0.01754386
## candidate quality
## -0.01754386
## issue salience
## -0.01754386
## inequality of opportunity vs outcome
## -0.01754386
## partisan donor advantage
## -0.01754386
## majority representation
## -0.01754386
## ideological representation
## -0.01754386
## partisan dislocation
## -0.01754386
## efficiency principle
## -0.01754386
## support for redistricting process
## -0.01754386
## floor votes align with state preferences
## -0.01754386
## degree of political conflict
## -0.01754386
Detect gerrymandering, public participation, floor votes align with district preferences, and constitutional tests are closest to all other concepts in the network.
Betweenness measures brokerage or gatekeeping potential. It is (approximately) the number of shortest paths between nodes that pass through a particular node. Sort the betweenness of the network and print it out.
| x | |
|---|---|
| partisan advantage | -113.5 |
| preserve communities of interest | -81.0 |
| number of competitive districts | -66.0 |
| partisan gerrymandering | -42.0 |
| efficiency gap | -25.5 |
| proportionality | -20.0 |
Partisan advantage has by far the highest measure of brokerage/gatekeeping potential, followed by number of competitive districts. These two concepts allow for the fastest facilitation of ideas in the redistricting network; in other words, if we were to design a causal story and try to connect two concepts, the fastest way to connect them would most often be through the idea of partisan advantage.
Eigenvector centrality is a measure of being well-connected connected to the well-connected. First eigenvector of the graph adjacency matrix. Only works with undirected networks. Sort the returned vector from the eigen_centrality of the network and print it out. (not for this application)
Page rank approximates probability that any message will arrive to a particular node. This algorithm was developed by Google founders, and originally applied to website links. Sort the returned vector from the page_rank of the network and print it out.
## computers
## 0.01001973
## mean-median vote comparison
## 0.01001973
## majority minority districts
## 0.01001973
## redistricting commission
## 0.01001973
## change in constituency boundaries
## 0.01001973
## sorting
## 0.01001973
## contiguity
## 0.01001973
## redistricting by courts
## 0.01001973
## upcoming redistricting
## 0.01001973
## geographic partisan distribution
## 0.01001973
## wasted votes
## 0.01001973
## identification with governing party
## 0.01001973
## electorate composition change
## 0.01143919
## legislative outcomes
## 0.01143919
## elite ideological moderation
## 0.01143919
## candidate quality
## 0.01143919
## issue salience
## 0.01143919
## degree of political conflict
## 0.01143919
## instability
## 0.01155583
## partisan donor advantage
## 0.01155583
## partisan gerrymandering
## 0.01265023
## stability in voters' fellow constituents
## 0.01265023
## number of minority representatives
## 0.01285865
## majority representation
## 0.01297529
## incumbent vote share
## 0.01326083
## personal vote
## 0.01326083
## campaign resource allocation
## 0.01326083
## floor votes align with district preferences
## 0.01392470
## number of competitive districts
## 0.01392470
## floor votes align with state preferences
## 0.01392470
## minority representation
## 0.01398102
## compactness
## 0.01398102
## split ticket voting
## 0.01400614
## voter information about their district
## 0.01406969
## public participation
## 0.01427811
## legislator voting
## 0.01534417
## ideological representation
## 0.01648987
## efficiency principle
## 0.01648987
## rolloff
## 0.01663664
## turnout
## 0.01796743
## constitutional test
## 0.01844471
## detect gerrymandering
## 0.01853650
## legislative majority-seeking behavior
## 0.01853650
## preserve communities of interest
## 0.01856823
## competitiveness
## 0.01995596
## support for redistricting process
## 0.01995596
## proportionality
## 0.02039484
## voter sense of place
## 0.02077242
## inequality of opportunity vs outcome
## 0.02577575
## house-senate delegation alignment
## 0.02735534
## voter turnout
## 0.02982121
## elite polarization
## 0.02989557
## efficiency gap
## 0.03044771
## pork spending
## 0.03327177
## partisan advantage
## 0.03675272
## equal population
## 0.06679818
## partisan dislocation
## 0.06679818
Authority score is another measure of centrality initially applied to the Web. A node has high authority when it is linked by many other nodes that are linking many other nodes. Sort the returned vector from the authority_score of the network and print it out.
## computers
## 0.0000000000
## mean-median vote comparison
## 0.0000000000
## majority minority districts
## 0.0000000000
## redistricting commission
## 0.0000000000
## change in constituency boundaries
## 0.0000000000
## sorting
## 0.0000000000
## contiguity
## 0.0000000000
## equal population
## 0.0000000000
## redistricting by courts
## 0.0000000000
## upcoming redistricting
## 0.0000000000
## incumbent vote share
## 0.0000000000
## personal vote
## 0.0000000000
## pork spending
## 0.0000000000
## voter sense of place
## 0.0000000000
## campaign resource allocation
## 0.0000000000
## legislative majority-seeking behavior
## 0.0000000000
## house-senate delegation alignment
## 0.0000000000
## geographic partisan distribution
## 0.0000000000
## inequality of opportunity vs outcome
## 0.0000000000
## partisan dislocation
## 0.0000000000
## wasted votes
## 0.0000000000
## identification with governing party
## 0.0000000000
## compactness
## 0.0005562909
## minority representation
## 0.0005562909
## public participation
## 0.0027184204
## split ticket voting
## 0.0057869838
## turnout
## 0.0063432747
## detect gerrymandering
## 0.0337160273
## electorate composition change
## 0.0505681727
## legislative outcomes
## 0.0505681727
## issue salience
## 0.0505681727
## degree of political conflict
## 0.0505681727
## partisan gerrymandering
## 0.0596445488
## stability in voters' fellow constituents
## 0.0596445488
## rolloff
## 0.0654315326
## number of minority representatives
## 0.0883222612
## voter turnout
## 0.0954434157
## ideological representation
## 0.1039825431
## efficiency principle
## 0.1039825431
## voter information about their district
## 0.1102127215
## preserve communities of interest
## 0.1227319331
## elite ideological moderation
## 0.1566570666
## candidate quality
## 0.1566570666
## support for redistricting process
## 0.1692878480
## competitiveness
## 0.1692878480
## instability
## 0.2910965686
## partisan donor advantage
## 0.2910965686
## number of competitive districts
## 0.3147015625
## floor votes align with district preferences
## 0.3147015625
## floor votes align with state preferences
## 0.3147015625
## legislator voting
## 0.3652697351
## constitutional test
## 0.3817387243
## proportionality
## 0.4186841056
## majority representation
## 0.4477536352
## elite polarization
## 0.7228157142
## efficiency gap
## 0.7670081250
## partisan advantage
## 1.0000000000
Finally, not exactly a measure of centrality, but we can learn more about who each node is connected to by using the following functions: neighbors (for direct neighbors) and ego (for neighbors up to n neighbors away). Find the neighbors of “partisan advantage”. Find the concept’s neighbors up to order 2 away.
## + 8/57 vertices, named, from 0bc61a5:
## [1] partisan advantage
## [2] proportionality
## [3] elite polarization
## [4] legislator voting
## [5] floor votes align with district preferences
## [6] number of competitive districts
## [7] efficiency gap
## [8] floor votes align with state preferences
## [[1]]
## + 30/57 vertices, named, from 0bc61a5:
## [1] partisan advantage
## [2] partisan gerrymandering
## [3] majority minority districts
## [4] redistricting commission
## [5] contiguity
## [6] proportionality
## [7] elite polarization
## [8] legislator voting
## [9] floor votes align with district preferences
## [10] number of competitive districts
## + ... omitted several vertices
Let’s now try to describe what a network looks like as a whole. We can start with measures of the size of a network. diameter is the length of the longest path (in number of edges) between two nodes. We can use get_diameter to identify this path. mean_distance is the average number of edges between any two nodes in the network. We can find each of these paths between pairs of edges with distances. Find the diameter and mean distances of the network.
## [1] 6
## + 7/57 vertices, named, from 0bc61a5:
## [1] number of competitive districts preserve communities of interest
## [3] partisan gerrymandering partisan advantage
## [5] proportionality house-senate delegation alignment
## [7] pork spending
## [1] 2.617284
## computers partisan advantage
## computers 0 5
## partisan advantage 5 0
## partisan gerrymandering 4 1
## preserve communities of interest 4 2
## mean-median vote comparison 2 3
## partisan gerrymandering
## computers 4
## partisan advantage 1
## partisan gerrymandering 0
## preserve communities of interest 1
## mean-median vote comparison 2
## preserve communities of interest
## computers 4
## partisan advantage 2
## partisan gerrymandering 1
## preserve communities of interest 0
## mean-median vote comparison 2
## mean-median vote comparison
## computers 2
## partisan advantage 3
## partisan gerrymandering 2
## preserve communities of interest 2
## mean-median vote comparison 0
edge_density is the proportion of edges in the network over all possible edges that could exist. Find the edge_density of the network.
## [1] 0.02161654
# 22*21 possible edges / 2 because it's undirected = 231 possible edges
# but only 60 exist
60/((22*21)/2)## [1] 0.2597403
reciprocity measures the propensity of each edge to be a mutual edge; that is, the probability that if i is connected to j, j is also connected to i. Find the reciprocity of the network – you should find that it is 1. Explain why you think reciprocity=1 in this case.
## [1] 0
transitivity, also known as clustering coefficient, measures that probability that adjacent nodes of a network are connected. In other words, if i is connected to j, and j is connected to k, what is the probability that i is also connected to k? Find the transitivity of the network.
## [1] 0.08780488
Networks often have different clusters or communities of nodes that are more densely connected to each other than to the rest of the network. Let’s cover some of the different existing methods to identify these communities.
The most straightforward way to partition a network is into connected components. Each component is a group of nodes that are connected to each other, but not to the rest of the nodes. For example, this network has two components.
Most networks have a single giant connected component that includes most nodes. Most studies of networks actually focus on the giant component (e.g. the shortest path between nodes in a network with two or more component is Inf!).
Components can be weakly connected (in undirected networks) or __strongly connected (in directed networks, where there is an edge that ends in every single node of that component).
Even within a giant component, there can be different subsets of the network that are more connected to each other than to the rest of the network. The goal of community detection algorithms is to identify these subsets.
There are a few different algorithms, each following a different logic.
The walktrap algorithm finds communities through a series of short random walks. The idea is that these random walks tend to stay within the same community. The length of these random walks is 4 edges by default, but you may want to experiment with different values. The goal of this algorithm is to identify the partition that maximizes a modularity score.
## IGRAPH clustering walktrap, groups: 10, mod: 0.54
## + groups:
## $`1`
## [1] "redistricting commission"
## [2] "elite ideological moderation"
## [3] "candidate quality"
## [4] "majority representation"
## [5] "identification with governing party"
## [6] "support for redistricting process"
##
## $`2`
## [1] "change in constituency boundaries"
## + ... omitted several groups/vertices
## IGRAPH clustering walktrap, groups: 7, mod: 0.56
## + groups:
## $`1`
## [1] "change in constituency boundaries" "electorate composition change"
## [3] "legislator voting" "legislative outcomes"
## [5] "incumbent vote share" "personal vote"
## [7] "campaign resource allocation" "issue salience"
## [9] "degree of political conflict"
##
## $`2`
## [1] "majority minority districts"
## [2] "redistricting commission"
## + ... omitted several groups/vertices
Other methods are:
## IGRAPH clustering edge betweenness, groups: 18, mod: 0.46
## + groups:
## $`1`
## [1] "computers"
##
## $`2`
## [1] "partisan advantage"
## [2] "change in constituency boundaries"
## [3] "sorting"
## [4] "elite polarization"
## [5] "legislator voting"
## [6] "legislative outcomes"
## + ... omitted several groups/vertices
## IGRAPH clustering infomap, groups: 1, mod: 0
## + groups:
## $`1`
## [1] "computers"
## [2] "partisan advantage"
## [3] "partisan gerrymandering"
## [4] "preserve communities of interest"
## [5] "mean-median vote comparison"
## [6] "majority minority districts"
## [7] "redistricting commission"
## [8] "change in constituency boundaries"
## [9] "competitiveness"
## + ... omitted several groups/vertices
## IGRAPH clustering label propagation, groups: 12, mod: 0.42
## + groups:
## $`1`
## [1] "computers" "public participation"
##
## $`2`
## [1] "partisan advantage"
## [2] "partisan gerrymandering"
## [3] "preserve communities of interest"
## [4] "redistricting commission"
## [5] "stability in voters' fellow constituents"
## [6] "proportionality"
## + ... omitted several groups/vertices
Infomap tends to work better in most social science examples (websites, social media, classrooms, etc), but fastgreedy is faster.
igraph also makes it very easy to plot the resulting communities:
# undirected graphs only
comm <- cluster_infomap(giant)
modularity(comm) # modularity score
par(mar=c(0,0,0,0)); plot(comm, giant)Alternatively, we can also add the membership to different communities as a color parameter in the igraph object.
The final way in which we can think about network communities is in terms of hierarchy or structure. We’ll discuss one of these methods.
K-core decomposition allows us to identify the core and the periphery of the network. A k-core is a maximal subnet of a network such that all nodes have at least degree K.
## computers
## 1
## partisan advantage
## 3
## partisan gerrymandering
## 3
## preserve communities of interest
## 3
## mean-median vote comparison
## 1
## majority minority districts
## 2
## redistricting commission
## 2
## change in constituency boundaries
## 2
## competitiveness
## 2
## sorting
## 1
## contiguity
## 1
## electorate composition change
## 1
## stability in voters' fellow constituents
## 1
## voter information about their district
## 2
## proportionality
## 2
## equal population
## 2
## redistricting by courts
## 1
## upcoming redistricting
## 1
## detect gerrymandering
## 1
## public participation
## 1
## constitutional test
## 2
## instability
## 1
## elite polarization
## 3
## number of minority representatives
## 1
## voter turnout
## 2
## legislator voting
## 2
## legislative outcomes
## 1
## incumbent vote share
## 1
## personal vote
## 1
## pork spending
## 1
## voter sense of place
## 1
## rolloff
## 2
## turnout
## 2
## split ticket voting
## 1
## campaign resource allocation
## 1
## floor votes align with district preferences
## 1
## minority representation
## 1
## elite ideological moderation
## 1
## legislative majority-seeking behavior
## 1
## candidate quality
## 1
## house-senate delegation alignment
## 1
## number of competitive districts
## 3
## issue salience
## 1
## geographic partisan distribution
## 1
## inequality of opportunity vs outcome
## 1
## compactness
## 2
## efficiency gap
## 3
## partisan donor advantage
## 1
## majority representation
## 2
## ideological representation
## 1
## partisan dislocation
## 2
## wasted votes
## 1
## identification with governing party
## 1
## efficiency principle
## 1
## support for redistricting process
## 1
## floor votes align with state preferences
## 1
## degree of political conflict
## 1
## named integer(0)
## computers
## 1
## mean-median vote comparison
## 5
## sorting
## 10
## contiguity
## 11
## electorate composition change
## 12
## stability in voters' fellow constituents
## 13
## redistricting by courts
## 17
## upcoming redistricting
## 18
## detect gerrymandering
## 19
## public participation
## 20
## instability
## 22
## number of minority representatives
## 24
## legislative outcomes
## 27
## incumbent vote share
## 28
## personal vote
## 29
## pork spending
## 30
## voter sense of place
## 31
## split ticket voting
## 34
## campaign resource allocation
## 35
## floor votes align with district preferences
## 36
## minority representation
## 37
## elite ideological moderation
## 38
## legislative majority-seeking behavior
## 39
## candidate quality
## 40
## house-senate delegation alignment
## 41
## issue salience
## 43
## geographic partisan distribution
## 44
## inequality of opportunity vs outcome
## 45
## partisan donor advantage
## 48
## ideological representation
## 50
## wasted votes
## 52
## identification with governing party
## 53
## efficiency principle
## 54
## support for redistricting process
## 55
## floor votes align with state preferences
## 56
## degree of political conflict
## 57
# Visualizing network structure
V(g)$coreness <- coreness(g)
par(mfrow=c(2, 3), mar=c(0.1,0.1,1,0.1))
set.seed(777); fr <- layout_with_fr(g)
for (k in 1:6){
V(g)$color <- ifelse(V(g)$coreness>=k, "orange", "grey")
plot(g, main=paste0(k, '-core shell'), layout=fr)
}## [1] 0.5387523
## computers
## 4
## partisan advantage
## 2
## partisan gerrymandering
## 2
## preserve communities of interest
## 2
## mean-median vote comparison
## 4
## majority minority districts
## 1
## redistricting commission
## 1
## change in constituency boundaries
## 3
## competitiveness
## 1
## sorting
## 2
## contiguity
## 2
## electorate composition change
## 8
## stability in voters' fellow constituents
## 6
## voter information about their district
## 3
## proportionality
## 2
## equal population
## 10
## redistricting by courts
## 1
## upcoming redistricting
## 9
## detect gerrymandering
## 4
## public participation
## 4
## constitutional test
## 2
## instability
## 2
## elite polarization
## 2
## number of minority representatives
## 1
## voter turnout
## 1
## legislator voting
## 3
## legislative outcomes
## 3
## incumbent vote share
## 8
## personal vote
## 8
## pork spending
## 7
## voter sense of place
## 6
## rolloff
## 3
## turnout
## 5
## split ticket voting
## 3
## campaign resource allocation
## 8
## floor votes align with district preferences
## 2
## minority representation
## 5
## elite ideological moderation
## 1
## legislative majority-seeking behavior
## 9
## candidate quality
## 1
## house-senate delegation alignment
## 7
## number of competitive districts
## 2
## issue salience
## 3
## geographic partisan distribution
## 2
## inequality of opportunity vs outcome
## 4
## compactness
## 5
## efficiency gap
## 2
## partisan donor advantage
## 2
## majority representation
## 1
## ideological representation
## 2
## partisan dislocation
## 11
## wasted votes
## 2
## identification with governing party
## 1
## efficiency principle
## 2
## support for redistricting process
## 1
## floor votes align with state preferences
## 2
## degree of political conflict
## 3
V(g)$shortname<-V(g)$name #shortened easier to read ver name
V(g)$shortname[V(g)$shortname=="concentration of likely donors in map-drawing party's districts"]<- "donor concentration"
V(g)$shortname[V(g)$shortname=="individual legislator voting"]<- "legislator voting"
V(g)$shortname[V(g)$shortname=="effect of personal vote"]<- "personal vote"
V(g)$shortname[V(g)$shortname=="detect gerrymandering"]<- "detect gerrymander"
V(g)$shortname[V(g)$shortname=="proportional minority representation"]<- "prop. minority rep"
V(g)$shortname[V(g)$shortname=="Number of competitive districts"]<- "no. competitive district"
V(g)$shortname[V(g)$shortname=="legislator information about district"]<- "legis. info on district"
V(g)$shortname[V(g)$shortname=="floor votes align with district preferences"]<- "legis. votes with district pref."
V(g)$shortname[V(g)$shortname=="stability in voters' fellow constituents"]<- "constituent stability"
V(g)$shortname[V(g)$shortname=="voter information about their district"]<- "voter info on district"
V(g)$shortname[V(g)$shortname=="legislator information seeking"]<- "legis. info-seek"
V(g)$shortname[V(g)$shortname=="Alignment of floor vote breakdown with statewide majority of voters"]<- "Floor vote align state voters"
V(g)$shortname[V(g)$shortname=="number of competitive districts" ]<- "no. competitive district"
V(g)$shortname[V(g)$shortname=="House-Senate Delegation alignment" ]<- "Congress-SH align"
V(g)$shortname[V(g)$shortname=="unconstitutional government interest"]<- "unconstit gov interest"
V(g)$shortname[V(g)$shortname=="number of minority representatives"]<- "no. minority reps"
V(g)$shortname[V(g)$shortname=="representation of majority opinion"]<- "represent majority opinion"
V(g)$shortname[V(g)$shortname=="elite ideological moderation"]<- "elite ideol moderation"
V(g)$shortname[V(g)$shortname=="partisan gerrymandering"]<- "partisan gerrymander"
V(g)$shortname[V(g)$shortname=="legislative majority-seeking behavior"]<- "legis majority-seeking behavior"
V(g)$shortname[V(g)$shortname=="change in constituency boundaries"]<- "change constituent boundary"
V(g)$shortname[V(g)$shortname=="demographic and ideological sorting"]<- "demog/ideol sorting"
V(g)$shortname[V(g)$shortname=="dispersed minority population"]<- "dispersed minority pop"
V(g)$shortname[V(g)$shortname=="majority minority districts"]<- "majority minority district"
set.seed(123)
pdf(file=here::here("figs","redistrict_communities.pdf"),width=13,height=13)
plot(g)
plot(wc, g, vertex.label=V(g)$shortname,vertex.label.dist=1,vertex.color="gray20")
dev.off()## png
## 2